<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>家居家具管理系统</title>

    <!-- begin::global styles -->
    <link rel="stylesheet" href="${APP_PATH}/assets/vendors/bundle.css" type="text/css">
    <!-- end::global styles -->



    <!-- begin::custom styles -->
    <link rel="stylesheet" href="${APP_PATH}/assets/css/app.css" type="text/css">
    <link rel="stylesheet" href="${APP_PATH}/assets/css/custom.css" type="text/css">
    <!-- end::custom styles -->

</head>
<body>

<!-- begin::page loader-->
<div class="page-loader">
    <div class="page-loader">
        <div class="spinner-border text-info"></div>
        <span>加载中 ...</span>
    </div>
</div>
<!-- end::page loader -->

<!-- begin::navigation -->
<jsp:include page="/WEB-INF/jsps/Manager/common/navigation.jsp"/>
<!-- end::navigation -->

<!-- begin::top -->
<jsp:include page="/WEB-INF/jsps/Manager/common/top.jsp"/>
<!-- end::top -->

<!-- begin::main content -->
<main class="main-content">

    <div class="container-fluid">

        <!-- begin::page header -->
        <div class="page-header d-md-flex justify-content-between align-items-center">
            <h4>订单详情</h4>
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb m-t-0">
                    <li class="breadcrumb-item"><a href="${APP_PATH}/toManager">首页</a></li>
                    <li class="breadcrumb-item"><a href="${APP_PATH}/toMyOrders?orderTarget=${requestScope.orderTarget}&pageNo=${requestScope.pageNo}">我的订单</a></li>
                    <li class="breadcrumb-item active" aria-current="page">订单详情</li>
                </ol>
            </nav>
        </div>
        <!-- end::page header -->


        <div class="card">
            <div class="card-body p-50">
                <div class="invoice">
                    <div class="d-flex justify-content-between align-items-center">
                        <h2 class="font-weight-800 d-flex align-items-center">
                            订单编号：${requestScope.orderInfo.order.onum}
                        </h2>
                        <h5 class="text-right m-b-0">下单时间：<fmt:formatDate value="${requestScope.orderInfo.order.otime}" type="both"/></h5>
                    </div>
                    <hr class="m-t-b-50">
                    <div class="row">
                        <div class="col-md-6">
                            <p>配送城市：${requestScope.orderInfo.addressInfo.province.pname} ${requestScope.orderInfo.addressInfo.city.cname}</p>
                            <p>配送区域：${requestScope.orderInfo.addressInfo.district.dname} ${requestScope.orderInfo.addressInfo.area.arname}</p>
                            <p>详细地址：${requestScope.orderInfo.addressInfo.address.address}</p>
                        </div>
                        <div class="col-md-6">
                            <p class="text-right">收货人：${requestScope.orderInfo.addressInfo.address.consignee}</p>
                            <p class="text-right">联系方式：${requestScope.orderInfo.addressInfo.address.cphone}</p>
                    </div>
                    </div>
                    <div class="table-responsive">
                        <table class="table m-t-b-50">
                            <thead>
                            <tr class="bg-dark text-white">
                                <th>#</th>
                                <th>商品名称</th>
                                <th class="text-right">订单数量</th>
                                <th class="text-right">商品单价</th>
                                <th class="text-right">小计</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${requestScope.orderInfo.pre_orderInfoList}" var="pre_orderInfo" varStatus="status">
                                <tr class="text-right">
                                    <td class="text-left">${status.count}</td>
                                    <td class="text-left">${pre_orderInfo.furniture.fname}(${pre_orderInfo.furnitureKinds.fkname})</td>
                                    <td>${pre_orderInfo.pre_order.count}</td>
                                    <td>￥<fmt:formatNumber type="number" value="${pre_orderInfo.furnitureKinds.fkprice}" pattern="#.00" /></td>
                                    <td>￥<fmt:formatNumber type="number" value="${pre_orderInfo.furnitureKinds.fkprice * pre_orderInfo.pre_order.count}" pattern="#.00" /></td>
                                </tr>
                            </c:forEach>

                            </tbody>
                        </table>
                    </div>
                    <div class="text-right">
                    <h4 class="font-weight-800">总价 : ￥${requestScope.orderInfo.order.oprice}</h4>
                        <br>
                    <p>付款方式: ${requestScope.orderInfo.order.paytype == 1?"在线支付":"货到付款"}</p>
                    </div>

                </div>
                <div class="text-right d-print-none">
                    <hr class="m-t-b-50">
                    <c:if test="${requestScope.orderInfo.order.otype == 0}">
                        <a href="javascript:;" onclick="sendOrder()" class="btn btn-info">
                            <i class="fa fa-send m-r-5"></i>&nbsp;&nbsp;发货
                        </a>
                    </c:if>
                   <c:if test="${requestScope.orderInfo.order.otype == 1}">
                       <a href="${APP_PATH}/toLogistics_Detail?oid=${requestScope.orderInfo.order.oid}" class="btn btn-info">
                           <i class="ti ti-truck"></i>&nbsp;&nbsp;查看物流
                       </a>
                   </c:if>
                    <a href="${APP_PATH}/toMyOrders?orderTarget=${requestScope.orderTarget}&pageNo=${requestScope.pageNo}"  class="btn btn-primary m-l-5">
                        <i class="ti ti-back-left"></i>&nbsp;&nbsp;返回
                    </a>
                </div>
            </div>
        </div>


        <!-- begin::bottom -->
        <div class="card-group">
            <jsp:include page="/WEB-INF/jsps/Manager/common/bottom.jsp"/>
        </div>
        <!-- end::bottom -->

    </div>



</main>
<!-- end::main content -->


<!-- begin::global scripts -->
<script src="${APP_PATH}/assets/vendors/bundle.js"></script>
<!-- end::global scripts -->


<!-- begin::custom scripts -->
<script src="${APP_PATH}/assets/js/custom.js"></script>
<script src="${APP_PATH}/assets/js/app.js"></script>
<!-- end::custom scripts -->


</body>
</html>

<script>
function sendOrder() {
    $.ajax({
        url : "${APP_PATH}/myOrders/sendOrder",
        method : "POST",
        data : {
            oid : '${requestScope.orderInfo.order.oid}'
        },
        success : function (result) {
            if(result.success){
                swal("发货成功！", {icon: "success"}).then((value) => {
                    window.location.href="${APP_PATH}/toOrder_Detail?oid=${requestScope.orderInfo.order.oid}&orderTarget=${requestScope.orderTarget}&pageNo=${requestScope.pageNo}";
            });
            }
        }
    });
}

</script>


